//
//  InformationViewController.m
//  NetMobileLocation
//
//  Created by Mehmet Sinan Şahin on 3/31/12.
//  Copyright (c) 2012 netgis. All rights reserved.
//

#import "InformationViewController.h"
#import "NGUtility.h"

@implementation InformationViewController

#pragma mark - button actions

- (IBAction) cancel: (id) sender {
    [self.view removeFromSuperview];
}

- (IBAction) copyDeviceID: (id) sender {
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    [pasteboard setString:[lblDeviceID text]];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle: TTLocalizedString(@"Copied", @"")
                                                    message: [lblDeviceID text]
                                                   delegate:nil
                                          cancelButtonTitle:TTLocalizedString(@"OK", @"")
                                          otherButtonTitles:nil];
    [alert show];
    [alert release]; 
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        nibNameOrNil = [nibNameOrNil stringByAppendingString:@"-ipad"];
    }
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [lblDeviceID setText:[NGUtility getDeviceId]];
    [lblTitleDeviceID setText:TTLocalizedString(@"Device ID", @"")];
    [btnCopy setTitle:TTLocalizedString(@"Copy", @"") forState:UIControlStateNormal];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void)dealloc {
    [lblDeviceID release];
    [super dealloc];
}

@end
